<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('nickname')->nullable();
            $table->string('avatar')->nullable();
            $table->string('avatar_key')->nullable();
            $table->string('mobile')->nullable()->index();
            $table->string('openid')->nullable()->unique();
            $table->string('unionid')->nullable()->unique();
            $table->string('session_key')->nullable();
            $table->string('official_account_openid')->nullable()->unique();
            $table->integer('referrer_id')->nullable()->index();
            $table->integer('has_order')->default(0);
            $table->integer('personal_id')->nullable();
            $table->string('invite_code')->nullable()->index();
            $table->integer('level')->default(0);
            $table->integer('share')->default(0);
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}
